package db;

import java.sql.ResultSet;
import java.sql.SQLException;

public class linhvuc {
	private String stt;
	private String malinhvuc;
	private String tenlinhvuc;
	public String getStt() {
		return stt;
	}
	public void setStt(String stt) {
		this.stt = stt;
	}
	public String getMalinhvuc() {
		return malinhvuc;
	}
	public void setMalinhvuc(String malinhvuc) {
		this.malinhvuc = malinhvuc;
	}
	public String gettenLinhvuc() {
		return tenlinhvuc;
	}
	public void settenLinhvuc(String linhvuc) {
		this.tenlinhvuc = linhvuc;
	}
	public linhvuc()
	{
		
		
	}
	public linhvuc(String malinhvuc,String tenlinhvuc)
	{
		super();
		this.malinhvuc=malinhvuc;
		this.tenlinhvuc=tenlinhvuc;
	}
	public int Save()
	{
		int i=0;
		String sql = "INSERT INTO linhvuc VALUES('"+malinhvuc+"','"+tenlinhvuc+"',"+"null"+")";
		i = Dbhandle.executeUpdate(sql);
		return i;
		
		
	}
	public static int Delete(String malinhvuc)
	{  
		int i = 0;
		String sql = "Delete from linhvuc where MALINHVUC ='"+malinhvuc+"'";
		i = Dbhandle.executeUpdate(sql);
		return i;
	
	}
public int Update()
{
	
	int i = 0;
	String sql = "UPDATE linhvuc SET  TENLINHVUC='"+tenlinhvuc+"'  WHERE MALINHVUC='"+malinhvuc+"'";
	i = Dbhandle.executeUpdate(sql);
	return i;
	
}
public static ResultSet SelectAll() throws SQLException
{
	String sql="SELECT * FROM linhvuc";
	ResultSet rs= Dbhandle.executeQuery(sql);
	return rs;
}
}
